package com.hex.ds.hdtp.core.inf.script.test.repository.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.common.page.Page;
import com.hex.ds.hdtp.core.inf.common.page.converter.IPageAndMyBatisPlusPageConverter;
import com.hex.ds.hdtp.core.inf.script.test.mapper.IScriptTestDataAnalysisMapper;
import com.hex.ds.hdtp.core.inf.script.test.po.ScriptTestDataAnalysisPo;
import com.hex.ds.hdtp.core.inf.script.test.repository.IScriptTestDataAnalysisRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.inf.script.test.repository.impl
 * @ClassName ScriptTestDataAnalysisRepository
 * @Description: 带数据测试数据分析结果-数据接口实现
 * @Author: wz.li
 * @Date 2023/8/1 15:04
 * @Version v2.0.2
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptTestDataAnalysisRepository implements IScriptTestDataAnalysisRepository {

    private final IScriptTestDataAnalysisMapper scriptTestDataAnalysisMapper;

    private final IPageAndMyBatisPlusPageConverter pageConverter;

    /*
     * @Method: queryListByPage <br>
     * @Param: [scriptTestDataAnalysisPo, toPage] <br>
     * @Return: com.hex.ds.hdtp.core.inf.common.page.Page<com.hex.ds.hdtp.core.inf.script.test.po.ScriptTestDataAnalysisPo> <br>
     * @Description：分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:04 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Page<ScriptTestDataAnalysisPo> queryListByPage(ScriptTestDataAnalysisPo scriptTestDataAnalysisPo, Page toPage) {
        final IPage tmpPageResult = scriptTestDataAnalysisMapper.queryListByPage(
                pageConverter.toMyBatisPlusPage(toPage)
                , scriptTestDataAnalysisPo
        );
        final List list = tmpPageResult.getRecords();
        final Page pageResult = pageConverter.toPage(tmpPageResult);
        return pageResult.setData(list);
    }

    /*
     * @Method: queryList <br>
     * @Param: [scriptTestDataAnalysisPo] <br>
     * @Return: java.util.List<com.hex.ds.hdtp.core.inf.script.test.po.ScriptTestDataAnalysisPo> <br>
     * @Description：不分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:04 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public List<ScriptTestDataAnalysisPo> queryList(ScriptTestDataAnalysisPo scriptTestDataAnalysisPo) {
        return scriptTestDataAnalysisMapper.queryList(scriptTestDataAnalysisPo);
    }

    /*
     * @Method: queryById <br>
     * @Param: [pkId] <br>
     * @Return: com.hex.ds.hdtp.core.inf.script.test.po.ScriptTestDataAnalysisPo <br>
     * @Description：根据主键查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:04 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public ScriptTestDataAnalysisPo queryById(String pkId) {
        return scriptTestDataAnalysisMapper.selectById(pkId);
    }

    /*
     * @Method: add <br>
     * @Param: [scriptTestDataAnalysisPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：新增<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:05 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer add(ScriptTestDataAnalysisPo scriptTestDataAnalysisPo) {
        return scriptTestDataAnalysisMapper.insert(scriptTestDataAnalysisPo);
    }

    /*
     * @Method: modifyById <br>
     * @Param: [scriptTestDataAnalysisPo] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键更新<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:05 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer modifyById(ScriptTestDataAnalysisPo scriptTestDataAnalysisPo) {
        return scriptTestDataAnalysisMapper.updateById(scriptTestDataAnalysisPo);
    }

    /*
     * @Method: removeById <br>
     * @Param: [pkId] <br>
     * @Return: java.lang.Integer <br>
     * @Description：根据主键删除<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 15:05 <br>
     * @Version： V2.0.2<br>
     */
    @Override
    public Integer removeById(String pkId) {
        return scriptTestDataAnalysisMapper.deleteById(pkId);
    }

}
